package com.loit.business.service;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.loit.business.dao.StudentDao;
import com.loit.business.entity.Student;
import java.util.List;



/**
 * [学生信息 ]服务实现.
 * Created by lifh on 2022-12-26.
 **/
@Service
@Transactional(readOnly = true)
public class StudentService{

    @Autowired
	  private StudentDao studentDao;

	/**                                                                                                                                      
	 * 分页列表                                                                                                                              
	 */                                                                                                                                      
    public IPage<Student> findListByPage(Page<Student> page, Student student){
        return studentDao.findList(page,student);
    }

	/**                                                                                                                                      
	 * 列表                                                                                                                              
	 */                                                                                                                                      
    public List<Student> findList(Student student){
        return studentDao.findList(student);
    }

	/**                                                                                                                                      
	 * 详情                                                                                                                              
	 */                                                                                                                                      
    public Student getById(int id){
        return studentDao.selectById(id);
    }

	/**                                                                                                                                      
	 * 保存                                                                                                                              
	 */                                                                                                                                      
    @Transactional(readOnly = false)
    public void insert(Student student){
        studentDao.insert(student);
    }

	/**                                                                                                                                      
	 * 修改                                                                                                                              
	 */                                                                                                                                      
    @Transactional(readOnly = false)
    public void update(Student student){
    UpdateWrapper<Student> updateWrapper = new UpdateWrapper<>();
    updateWrapper.eq("id", student.getId());
        studentDao.update(student,updateWrapper);
    }

	/**                                                                                                                                      
	 * 删除                                                                                                                              
	 */                                                                                                                                        
    @Transactional(readOnly = false)
    public void delete(Integer id){
        studentDao.deleteById(id);
    }

}